#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->lineEdit->setEchoMode(QLineEdit::Password);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);
    ui->label->setText("请输入您的密码：");
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_lineEdit_textEdited(const QString &arg1)
{
    (void)arg1;
    const QString& ret = ui->lineEdit->text();
    const QString& ret2 = ui->lineEdit_2->text();
    if(ret.isEmpty() && ret2.isEmpty())
        ui->label->setText("未输入");
    else if(ret == ret2)
        ui->label->setText("两次输入的密码相同");
    else if(ret.size() == ret2.size() && !(ret == ret2))
        ui->label->setText("两次输入的密码不相同");
    else
        ui->label->setText("请按格式输入");
}

void Widget::on_lineEdit_2_textEdited(const QString &arg1)
{
    (void)arg1;
    const QString& ret = ui->lineEdit->text();
    const QString& ret2 = ui->lineEdit_2->text();
    if(ret.isEmpty() && ret2.isEmpty())
        ui->label->setText("未输入");
    else if(ret == ret2)
        ui->label->setText("两次输入的密码相同");
    else if(ret.size() == ret2.size() && !(ret == ret2))
        ui->label->setText("两次输入的密码不相同");
    else
        ui->label->setText("请按格式输入");
}
